package ru.aslanov.schedule.server;

import javax.servlet.*;
import java.io.IOException;
import java.util.logging.Logger;

/**
 * Created by IntelliJ IDEA.
 * Created: Jul 9, 2010 4:02:46 PM
 *
 * @author Sergey Aslanov
 */
public class PersistanceManagerFilter implements javax.servlet.Filter {
    private static final Logger log = Logger.getLogger(PersistanceManagerFilter.class.getName());

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        try {
            filterChain.doFilter(servletRequest, servletResponse);
        } finally {
            PMF.closeThreadLocalPersistenceManager();
        }
    }

    @Override
    public void destroy() {
    }
}
